/**
 * @program: 11.23
 * @description:
 * @author: 李鑫月
 * @create: 2021-11-23 09:04
 **/

/**
 * 创建对象的方法：
 * 1.new（）
 * 2.clone 方法
 */
class Meony implements Cloneable{
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    double num;
}
class Person implements Cloneable{
    int age;
    Meony meony=new Meony();
    void eat(){
        System.out.println("eat");
    }

    @Override
    public String toString() {
        return super.toString();
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Person tmp=(Person) super.clone();
        tmp.meony=(Meony) this.meony.clone();
        return tmp;
    }
}
public class Test {
    public static void main(String[] args) throws CloneNotSupportedException {
        Person person=new Person();
        person.age=99;
        Person person1=(Person) person.clone();
        System.out.println(person1.age);
        person1.meony.num=12.1;
        System.out.println(person.meony.num);
    }
}
